package com.hqully.smartfumehood.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hqully.smartfumehood.common.utils.VerifyUtil;
import com.hqully.smartfumehood.common.vo.QueryVo;
import com.hqully.smartfumehood.entity.FumeHoodData;
import com.hqully.smartfumehood.mapper.DevErrorMapper;
import com.hqully.smartfumehood.service.FumeHoodDataService;
import com.hqully.smartfumehood.mapper.FumeHoodDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author ZH.ming
* @description 针对表【fume_hood_data】的数据库操作Service实现
* @createDate 2022-06-24 10:30:48
*/
@Service
public class FumeHoodDataServiceImpl extends ServiceImpl<FumeHoodDataMapper, FumeHoodData>
    implements FumeHoodDataService{

    @Autowired
    private FumeHoodDataMapper  fumeHoodDataMapper;


    @Override
    public int addFumeHoodData(FumeHoodData fumeHoodData) {
        return fumeHoodDataMapper.addFumeHoodData(fumeHoodData);
    }


    @Override
    public PageInfo<FumeHoodData> findAllByAPIdAndVavId(QueryVo queryVo) {
        PageHelper.startPage(queryVo.getPageNum(),queryVo.getPageSize(),true);

        List<FumeHoodData> fumeHoodDataList = fumeHoodDataMapper.findAllByAPIdAndVavId(queryVo.getQuery());

        PageInfo<FumeHoodData> fumeHoodDataPageInfo = new PageInfo<>(fumeHoodDataList);
        return fumeHoodDataPageInfo;
    }

    @Override
    public PageInfo<FumeHoodData> findAllByVavId(QueryVo queryVo) {
        PageHelper.startPage(queryVo.getPageNum(),queryVo.getPageSize(),true);

        List<FumeHoodData> fumeHoodDataList = fumeHoodDataMapper.findAllByVavId(queryVo.getQuery());

        PageInfo<FumeHoodData> fumeHoodDataPageInfo = new PageInfo<>(fumeHoodDataList);
        return fumeHoodDataPageInfo;
    }

    @Override
    public boolean verifyFumeHoodData(FumeHoodData fumeHoodData) {

        Float speedS = fumeHoodData.getSpeedS();

        Float dis = fumeHoodData.getDis();

        Integer angle = fumeHoodData.getAngle();

        return VerifyUtil.inInterval(speedS, 0, 0.8)
                && VerifyUtil.inInterval(dis, 0f, 80f)
                && VerifyUtil.inInterval(angle, 0, 90);
    }
}




